package dao.entities.control;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotEmpty;

import utils.SessionUtils;
import views.annotations.View;
import dao.interfaces.IBase;

@Entity
@Table(schema = "GENERAL", name = "PROVACIENTIFICA")
@View.Views({ @View(name = "table", fields = ""),
		@View(name = "record", fields = "") ,
		@View(name = "selector", fields = "id,description")})
public class ProvaCientifica implements IBase {

	@Column(unique = true)
	@NotEmpty
	private String description;


	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	private String notes;
	private String user;
	private Date date;

	@PreUpdate
	@PrePersist
	private void updateSave() {
		date = new Date();
		user = (String) SessionUtils.getSessionAttribute("user");
	}

	@Override
	public Object getId() {
		return id;
	}

	@Override
	public void setId(Object id) {
		this.id = (long) id;
	};

	@Override
	public String getDescription() {
		return description;
	};

	@Override
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public String getNotes() {
		return notes;
	};

	@Override
	public void setNotes(String notes) {
		this.notes = notes;
	}

	@Override
	public String getUser() {
		return user;
	};

	@Override
	public void setUser(String user) {
		this.user = user;
	}

	@Override
	public Date getDate() {
		return date;
	}

	@Override
	public void setDate(Date date) {
		this.date = date;
	}

	public ProvaCientifica() {
		super();
	}

	public ProvaCientifica(String description, String notes, String user,
			Date date) {
		super();
		this.description = description;
		this.notes = notes;
		this.user = user;
		this.date = date;
	}

	@Override
	public String toString() {
		return description;
	}



}
